package com.zbkj.admin.controller;

import com.zbkj.admin.service.IAdminStandardHandleService;
import com.zbkj.common.request.standard.AddleafRequest;
import com.zbkj.common.request.standard.UptStandRequest;
import com.zbkj.common.response.CommonResult;
import com.zbkj.common.response.project.AiReportResponse;
import com.zbkj.common.response.standard.HumcoutResponse;
import com.zbkj.common.response.standard.ProductivityResponse;
import com.zbkj.common.response.standard.ReportDetailResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @Auther:
 * @Date: 2024/9/13 08:55
 * @Description:
 */
@Slf4j
@RestController
@RequestMapping("api/admin/standard")
@Api(tags = "服务端标准控制层")
public class AdminStandardController {

    @Autowired
    private IAdminStandardHandleService adminStandardHandleService;

    @ApiOperation(value="标准新增叶子节点")
    @PostMapping("/addLeaf")
    public CommonResult<Long> addLeaf(@RequestBody AddleafRequest addleafRequest) {
        return CommonResult.success(adminStandardHandleService.addLeaf(addleafRequest));
    }

    @ApiOperation(value="标准开发费用估算")
    @GetMapping("/reportDetail/{standardId}")
    public CommonResult<List<ReportDetailResponse>> reportDetail(@PathVariable("standardId") Long projectId, HttpServletResponse response) throws Exception {
        return CommonResult.success(adminStandardHandleService.getReportDetail(projectId, response));
    }

    @ApiOperation(value="基准生产率")
    @GetMapping("/productivity/{standardId}")
    public CommonResult<List<ProductivityResponse>> productivity(@PathVariable("standardId") Long standardId) {
        return CommonResult.success(adminStandardHandleService.productivity(standardId));
    }

    @ApiOperation(value="平均人力成本费率")
    @GetMapping("/humcost/{standardId}")
    public CommonResult<List<HumcoutResponse>> humcost(@PathVariable("standardId") Long standardId) {
        return CommonResult.success(adminStandardHandleService.humcost(standardId));
    }

    @ApiOperation(value="标准更新")
    @PostMapping("/uptStandard")
    public CommonResult uptStandard(@RequestBody List<UptStandRequest> uptStandRequestLs) {
        adminStandardHandleService.uptStandard(uptStandRequestLs);
        return CommonResult.success();
    }
}
